package com.java.day06;

public class Fish extends Animal implements Comparable<Fish>{
    //鳞片颜色
    private String scaleColor;

    public Fish() {
    }

    public Fish(String scaleColor) {
        this.scaleColor = scaleColor;
    }

    public Fish(String name, int age, String sex, String type, String scaleColor) {
        super(name, age, sex, type);
        this.scaleColor = scaleColor;
    }

    public void swim() {
        System.out.println(getName() + "游泳");
    }


    public void setScaleColor(String scaleColor) {
        this.scaleColor = scaleColor;
    }

    public String getScaleColor() {
        return scaleColor;
    }

    @Override
    public String toString() {
        return "Fish{" +
                ",scaleColor='" + scaleColor + '\'' +
                ", name='" + getName() + '\'' +
                ", age=" + getAge() + '\'' +
                ", sex='" + getSex() + '\'' +
                ", type='" + getType() + '\'' +
                '}';
    }

//    @Override
//    public int compareTo(Fish o) {
//        int age = this.getAge();
//        int targetAge = o.getAge();
//        if (age == targetAge){
//            String name = this.getName();
//            String targetName = o.getName();
//            return name.compareTo(targetName);
//        }else{
//            return age-targetAge;
//        }
//
//    }


    @Override
    public int compareTo(Fish o) {
        String name = this.getName();
        String targetName = o.getName();

        return name.length()-targetName.length();
    }
}
